package com.ly.controller;

import com.ly.pojo.Article;
import com.ly.pojo.Result;
import com.ly.service.ArticleService;
import com.ly.utils.JwtUtil;
import com.ly.utils.PageBean;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;
    @PostMapping
   public Result add(@RequestBody @Validated Article article){
        articleService.add(article);
        return Result.succces("文章添加成功");
   }
   @GetMapping("/list")
   public Result<PageBean<Article>> list(
           Integer pageNum,
           Integer pageSize,
           @RequestParam(required = false) Integer category,
           @RequestParam(required = false) String state
   ){
        PageBean<Article> pb= articleService.list(pageNum,pageSize,category,state);
        return Result.success(pb);
   }

}
